using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlashBack : MonoBehaviour
{
    // 颜色
    public Color[] colorSequence = new Color[]
    {
        new Color(0xee/255f,0x75/255f,0x36/255f),
        new Color(0xe0/255f,0x55/255f,0x00/255f),
        new Color(0xa0/255f,0x30/255f,0x00/255f),
        new Color(0xe0/255f,0x55/255f,0x00/255f),
    };
    public float intervalTime=8f/60f;

    private float lastTime;
    private int index=0;
    private SpriteRenderer sr;

    void Awake()
    {
        lastTime = Time.time;
        sr=GetComponent<SpriteRenderer>();
    }

    private void FixedUpdate()
    {
        if (colorSequence.Length > 0)
        {
            sr.color = colorSequence[index];
            float t = Time.time - lastTime;
            if (t >= intervalTime)
            {
                lastTime = Time.time;
                index++;
                if (index >= colorSequence.Length)
                {
                    index = 0;
                }
            }
        }

    }
}
